package dfbz.数组排序;

public class Test02 {
    public static void main(String[] args) {
        int[] arr={5,4,2,1,3};
        selectionSort(arr);
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static int[] selectionSort(int[] arr){
        for (int i = 0; i <arr.length ; i++) {    //比较的堂叔
            for (int j = 0; j <arr.length-1-i ; j++) {  //每一趟比价的次数
                if(arr[j]>arr[j+1]){ //谁和谁比
                    int temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
        return arr;
    }
}
